
package com.jf.cloud.user.feign;

import com.jf.cloud.api.user.dto.FinanceDetailDTO;
import com.jf.cloud.api.user.vo.FinanceDetailExcelVO;
import com.jf.cloud.api.user.vo.FinanceDetailVO;
import com.jf.cloud.api.user.dto.UserTypeDTO;
import com.jf.cloud.api.user.feign.UserLevelLogClient;
import com.jf.cloud.common.database.dto.PageDTO;
import com.jf.cloud.common.database.vo.PageVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.user.model.UserLevelLog;
import com.jf.cloud.user.service.UserLevelLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Hidden;

import java.util.List;

/**
 * 会员等级日志
 * @author zz
 */
@RestController
@Hidden
public class UserLevelLogFeignController implements UserLevelLogClient {

    @Autowired
    private UserLevelLogService userLevelLogService;

    @Override
    public ServerResponseEntity<Long> getPayAmount(Long userLevelLogId) {
        UserLevelLog userLevelLog = userLevelLogService.getByLevelLogId(userLevelLogId);
        return ServerResponseEntity.success(userLevelLog.getPayAmount());
    }

    @Override
    public ServerResponseEntity<Integer> getIsPay(Long userLevelLogId) {
        UserLevelLog userLevelLog = userLevelLogService.getByLevelLogId(userLevelLogId);
        return ServerResponseEntity.success(userLevelLog.getIsPayed());
    }

    @Override
    public ServerResponseEntity<Integer> getUserTypeAtTime(UserTypeDTO userTypeDTO) {
        return ServerResponseEntity.success(userLevelLogService.getUserTypeAtTime(userTypeDTO.getUserId(), userTypeDTO.getCreateTime()));
    }

    @Override
    public ServerResponseEntity<PageVO<FinanceDetailVO>> pageFinanceDetail(FinanceDetailDTO financeDetailDTO) {
        PageDTO pageDTO = new PageDTO();
        pageDTO.setPageSize(financeDetailDTO.getPageSize());
        pageDTO.setPageNum(financeDetailDTO.getPageNum());
        PageVO<FinanceDetailVO> result = userLevelLogService.pageFinanceDetail(pageDTO, financeDetailDTO);
        return ServerResponseEntity.success(result);
    }

    @Override
    public ServerResponseEntity<List<FinanceDetailExcelVO>> listFinanceDetail(FinanceDetailDTO financeDetailDTO) {
        List<FinanceDetailExcelVO> listFinanceDetail = userLevelLogService.listFinanceDetail(financeDetailDTO);
        return ServerResponseEntity.success(listFinanceDetail);
    }

}
